<%@ page import="java.sql.Statement" import="java.sql.ResultSet" import="java.sql.Connection" import="java.sql.DriverManager"%>
<%@page import="connection.DBConnection"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title> Journal Periodic Report</title>
</head>
<body>
<h2 align="center"> Journal Periodic Report</h2>
<form name="fr15" method="post">

  <%
        String exportToExcel = request.getParameter("exportToExcel");
        if (exportToExcel != null && exportToExcel.toString().equalsIgnoreCase("YES")) 
        {
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Content-Disposition", "inline; filename=" + "JournalPeriodicReport.xls");
 
        }
    %>

<table border=2 align="center"> 

<tr>
		<th> Voucher Entry Number </th>
		<th> Date </th>
		<th> Account Debited </th>
		<th> Amount </th>
		<th> Account Credited </th>
		<th> Amount </th>
		<th> Narration </th>
			 
</tr>

		<%
        String dte=(String) request.getAttribute("frmdte");
		 String dte1=(String) request.getAttribute("todte");
			
			
			double amount4=0.0,amount6=0.0;
			double jv4=0.0,jv6=0.0;
			try
			{
				String qry;
            Class.forName("com.mysql.jdbc.Driver");
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost/boa","root","root");
            Statement s = con.createStatement();                
            qry=" Select * from journalvoucher where CAST(date as DATE) between '"+dte+"' and '"+dte1+"';";
            ResultSet rs=s.executeQuery(qry);
       		  while(rs.next()){ %>
<tr>
            		<td><%= rs.getString(1)%></td>
            		<td><%= rs.getString(2)%></td>
            		<td><%= rs.getString(3)%></td>
            		
            		<% jv4= rs.getDouble(4); %>
            		<td><%=jv4 %></td>
            		<td><%= rs.getString(5)%></td>
            		
            		<% jv6= rs.getDouble(6); %>
            		<td><%=jv6%></td>
            		<td><%= rs.getString(7)%></td>
            		
</tr>
        		<% 
        			amount4=amount4+jv4;
        			amount6=amount6+jv6;
        			} %>
  
	 		<% }
			catch(Exception e){} %>
			
<tr>
	<td> <b> Total </b></td>
	<td> </td>
	<td> </td>
	<td> <%=amount4 %> </td>
	<td> </td>
	<td> <%=amount6 %> </td>
	<td> </td>
</tr>
<!-- 
<tr>
		<td> ${CMR.jname} </td> 
		<td> ${CMR.date} </td>
		<td> ${CMR.jaccdeb} </td>
		<td> ${CMR.jamount1} </td>
		<td> ${CMR.jaccred} </td>
		<td> ${CMR.jamount2} </td>
		<td> ${CMR.jnar} </td>
		
</tr>
-->
</table><br><br> 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

    <%
        if (exportToExcel == null) {
    %>
    <a href="JournalPeriodicReport.jsp?exportToExcel=YES">Export to Excel</a>
    <%
        }
    %>
</form>


</body>
</html>